﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataLayer.Interfaces;

namespace DataLayer.Implementations
{
    public class GeneralApplication<T> where T : class
    {
        protected INHibernateModel model = NHibernateModel.GetInstance();

        protected void Save(T target, int id) 
        {
            model.InsertOrUpdate<T>(target, id);
        }

        public void Save(List<T> list)
        {
            model.InsertOrUpdate<T>(list);
        }

        public IList<T> GetAll()
        {
            return model.GetAll<T>();
        }

        public IList<T> GetAll(string orderBy, bool asc)
        {
            return model.GetAll<T>(orderBy, asc);
        }

        public T GetById(int id)
        {
            return model.GetById<T>(id);
        }

        public void Delete(List<T> list)
        {
            model.Delete(list);
        }
    }
}
